package com.queen.testretrofitrxjava.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.facebook.drawee.backends.pipeline.Fresco;
import com.queen.testretrofitrxjava.R;
import com.queen.testretrofitrxjava.applications.ApplicationController;
import com.queen.testretrofitrxjava.ui.fragments.MainFragment;

public class MainActivity extends AppCompatActivity {

    public static final String TAG = MainActivity.class.getSimpleName();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        Fresco.initialize(this);

        setContentView(R.layout.activity_main);

        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.activity_main_RL, new MainFragment())
                .commit();
    }

    @Override
    public void onBackPressed() {

        if (getSupportFragmentManager().getBackStackEntryCount() > 0) {
            getSupportFragmentManager().popBackStack();
        } else {
            super.onBackPressed();
        }
    }

    @Override
    protected void onStart() {
        super.onStart();

        ApplicationController.getsInstance().addActivity(this);
    }

    @Override
    protected void onStop() {
        super.onStop();

        ApplicationController.getsInstance().deleteActivity(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }

}
